package net.jcip.examples.counters;

public class SyncCounter implements LongCounter {

    private Object lock = new Object();

    private long counter = 0;

    @Override
    public void reset() {
        counter = 0;
    }

    @Override
    public void increment() {
        synchronized (lock) {
            ++counter;
        }
    }

    @Override
    public long getCounter() {
        synchronized (lock) {
            return counter;
        }
    }
}
